﻿using System.Collections.Generic;
using System.Linq;
using MaxStoreErp.Core.Extensions;
using MaxStoreShop.Domain.Directories;
using MaxStoreShop.Logic.RepositoriesContracts.Directories;

namespace MaxStoreShop.Dal.Repositories.Directories
{
    public class ProductCategoryRepository : RepositoryBase, IProductCategoryRepository
    {
        public IEnumerable<ProductCategory> GetAllProductCategories()
        {
            return Context.ProductCategories.AsNoTracking().NotDeleted();
        }

        public void DeleteProductCategory(int productCategoryId)
        {
            SafeDelete(Context.ProductCategories.First(c => c.Id == productCategoryId));
        }

        public void SaveProductCategory(ProductCategory productCategory)
        {
            SaveEntity(productCategory);
        }
    }
}
